var remusername =tool.getCookie('remusername')
console.log(remusername)
if(remusername){
    $('input[name="username"]').val(remusername)
}
$('.lg').click(function(){
    if($('input[name="username"]').val()===""){
        layer.msg('用户名不能为空',{
            icon :2,
            time:1500

        })
        return false
    }
    if($('input[name="password"]').val()===""){
        layer.msg('密码不能为空',{
            icon :2,
            time:1500
        })
        return false
    }
    var loadindex= layer.load(0,{
        shade:[0.8,"#000"]
    })
    $(this).prop('disabled',true)
    $.post('./php/login.php',{
        username:$('input[name="username"]').val(),
        password:$('input[name="password"]').val()
    },res=>{
        var {meta:{status,msg},data}=res;
        layer.close(loadindex)
        if(status===1){
            layer.msg(msg,{
                icon:1,
                time:1500
            },
            function(){
                tool.setCookie('username',$('input[name="username"]').val(),7200)
                if($('input[name="remeber"]').prop('checked')){
                    tool.setCookie('remusername',$('input[name="username"]').val(),3600*24*7)
                }
                var url =localStorage.getItem('url')
                if(url){
                    localStorage.removeItem('url')
                    location.href=url
                }else{
                location.href="index.html"
                }
            })
        }else{
            layer.msg(msg,{
                icon:2,
                time:1500
            })
       $(this).prop('disabled',false)

            $('.tishi').css("display","block")
            setTimeout(function(){
            $('.tishi').css("display","none");
            },3000)
            return false
        }
    },'json')
    return false;
})